package com.ruoyi.project.notice.manager.service;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.project.notice.manager.domain.NoticeManager;
import com.ruoyi.project.notice.manager.mapper.NoticeManagerMapper;
import com.ruoyi.project.notice.type.domain.NoticeType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeManagerServiceImpl  implements NoticeManagerService {

    @Autowired
    private NoticeManagerMapper noticeManagerMapper;

    @Override
    public List<NoticeManager> selectAll(NoticeManager noticeManager) {
        return noticeManagerMapper.selectAll(noticeManager);
    }


    @Override
    public Integer insert(NoticeManager noticeManager) {
        return noticeManagerMapper.insert(noticeManager);
    }

    @Override
    public String checkManagerNameUnique(NoticeManager noticeManager) {
        NoticeManager type = noticeManagerMapper.selectOne(noticeManager);

        if(type!=null){
            return UserConstants.TYPE_NAME_NOT_UNIQUE;
        }
        return UserConstants.TYPE_NAME_UNIQUE;
    }


    @Override
    public NoticeManager selectTypeById(Long id) {
        return noticeManagerMapper.selectByID(id);
    }


    @Override
    public Integer update(NoticeManager noticeManager) {
        return noticeManagerMapper.update(noticeManager);
    }
}
